<script setup>
import HeaderNav from '@/components/HeaderNav.vue'
import HouseCardItem from "@/components/HouseCardItem.vue";
import {myCollectApi} from "@/api/house/house-collect.js";
import store from '@/store'

const currentUser = store.state.value.user// 当前登录的用户存储状态
const houseList = ref([])
onMounted(() => {
  myCollectApi(currentUser.id).then(res => {
    houseList.value = res.rows
  })
})
</script>

<template>
  <div class="box">
    <header-nav :active="2" style="width: 100vw;"/>
    <el-row :gutter="48" justify="center" style="padding: 0 48px;margin-top: 20px;"
            v-if="houseList && houseList.length>0">
      <el-col :span="7" v-for="item in houseList" :key="item.id">
        <HouseCardItem :house="item"/>
      </el-col>
    </el-row>
    <div v-else class="empty">
      您还没有收藏任何房源哦~请去浏览一下吧~
      <div class="more">
        查看更多
      </div>
    </div>
  </div>
</template>

<style scoped lang="less">
.box {
  width: 100%;
}

.empty {
  width: 100%;
  text-align: center;
  font-size: 30px;
  color: #999;
  padding: 20px;
  margin-top: 20vh;
}

.more {
  width: 200px;
  height: 60px;
  line-height: 60px;
  color: #fff;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  text-align: center;
  margin: 30px auto;
  background: #1ab394;
}
</style>
